package com.exchange.View;

import android.app.Dialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager.LayoutParams;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.exchange.Controller.ExchangeDataService;
import com.exchange.Controller.MoreFinishListener;
import com.exchange.Controller.a;
import com.exchange.Public.ExchangeConstants;
import com.exchange.Public.n;
import com.exchange.View.a.a;
import com.exchange.View.a.e;
import com.exchange.b.a;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class x extends Dialog
{
  public static MoreFinishListener a;
  private Context b;
  private ExchangeDataService c;
  private ListView d;
  private View e;
  private TextView f;
  private ImageView g;
  private List<a> h;
  private ah i;
  private int j;

  private View a()
  {
    return ((LayoutInflater)this.b.getSystemService("layout_inflater")).inflate(a.x(this.b), null);
  }

  private List<a> a(List<a> paramList)
  {
    StringBuilder localStringBuilder1;
    StringBuilder localStringBuilder2;
    Iterator localIterator2;
    Iterator localIterator3;
    ArrayList localArrayList = new ArrayList();
    Iterator localIterator1 = paramList.iterator();
    if (!(localIterator1.hasNext()))
      if (ExchangeConstants.DEBUG_MODE)
      {
        localStringBuilder1 = new StringBuilder();
        localStringBuilder2 = new StringBuilder();
        localIterator2 = localArrayList.iterator();
        if (localIterator2.hasNext())
          break label186;
        localIterator3 = paramList.iterator();
      }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          a locala;
          do
          {
            if (localIterator3.hasNext())
              break label217;
            n.c(ExchangeConstants.LOG_TAG, "Showing next page data, before filtered: " + localStringBuilder2.toString());
            n.c(ExchangeConstants.LOG_TAG, "Showing next page data, after filtered: " + localStringBuilder1.toString());
            return localArrayList;
            locala = (a)localIterator1.next();
          }
          while ((locala.m == 1) || (a(locala.j, this.h)));
          localArrayList.add(locala);
        }
        label186: localStringBuilder1.append(((a)localIterator2.next()).g);
        localStringBuilder1.append(", ");
      }
      label217: localStringBuilder2.append(((a)localIterator3.next()).g);
      localStringBuilder2.append(", ");
    }
  }

  private static boolean a(String paramString, List<a> paramList)
  {
    int k;
    if (paramString == null)
      k = 0;
    while (true)
    {
      return k;
      Iterator localIterator = paramList.iterator();
      do
        while (!(localIterator.hasNext()))
          k = 0;
      while (!(paramString.equalsIgnoreCase(((a)localIterator.next()).j)));
      k = 1;
    }
  }

  private void b()
  {
    this.e.setVisibility(4);
    this.d.addFooterView(this.e);
    this.i = new ah(this.d, this.b, a.m(this.b), false, this.h, 7);
    a locala = new a(this, this.c);
    if (this.d != null)
    {
      this.d.setOnScrollListener(locala);
      this.c.page_index = 0;
    }
    new a(this.b, 0, this.h, 7, this.j, 0).start();
    this.d.postDelayed(new w(this, locala), 1500L);
  }

  public class a
  implements AbsListView.OnScrollListener
  {
    private ExchangeDataService b;

    public a(, ExchangeDataService paramExchangeDataService)
    {
      this.b = paramExchangeDataService;
    }

    public void a()
    {
      ai localai = new ai(this);
      if (x.b(this.a) != null)
      {
        x.b(this.a).setText("更多精彩推荐  ");
        x.c(this.a).setClickable(false);
        Animation localAnimation = AnimationUtils.loadAnimation(x.f(this.a), e.f(x.f(this.a)));
        x.h(this.a).setVisibility(0);
        x.h(this.a).startAnimation(localAnimation);
        x.c(this.a).setVisibility(0);
      }
      this.b.pagination = true;
      ExchangeDataService localExchangeDataService = this.b;
      localExchangeDataService.page_index = (1 + localExchangeDataService.page_index);
      this.b.requestDataAsyn(x.f(this.a), localai);
    }

    public void onScroll(, int paramInt1, int paramInt2, int paramInt3)
    {
    }

    public void onScrollStateChanged(, int paramInt)
    {
      n.c(ExchangeConstants.LOG_TAG, "onScrolled.");
      if ((Math.abs(x.a(this.a).getLastVisiblePosition() - x.a(this.a).getCount()) <= 2) && (paramInt == 0))
      {
        n.c(ExchangeConstants.LOG_TAG, "requesting next page...");
        a();
      }
    }
  }
}